package com.namuan.jp_stock.object;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Timestamp {
	
	public String timestmsp(String dates) {
		Date today = new Date();//현재날짜 
		Calendar todayCal = new GregorianCalendar();
		todayCal.setTime(today);
		Date article_date = new Date(new Long(dates));//파라미터 날짜값 
		Calendar article_dateCal = new GregorianCalendar();
		todayCal.setTime(article_date);
	    String date = "";//리턴값  
	    long d, h, m;//일,시간,분 
	    d = ((article_dateCal.getTimeInMillis()-todayCal.getTimeInMillis())/ 24 / 60 / 60 / 1000);//일수 계산  
	    if (d < 1) {//시간 계산  
	        h = (article_dateCal.getTimeInMillis()-todayCal.getTimeInMillis())/ 60 / 60 / 1000;   
	        m = (article_dateCal.getTimeInMillis()-todayCal.getTimeInMillis())/ 60 / 1000;   
	        h = m / 60 ;   
	        m = m % 60 ;   
	        if (h > 0) {   
	            date = h + "시간 ";   
	        }   
	        else  
	            if (m < 60) {   
	                date += m + "분"; 
	            }   
	            else {   
	                date = "알수없는 날짜 포멧입니다..";   
	            }
	return date +"전";  
	    }   
	    else {   	    	
	        return (article_date.getMonth()+1)+"/"+(article_date.getDate()+1)+"/"+(article_date.getYear()+1900);
	    }
	    
	}
	
	
}
	

